<template>
  <div id="app">
    <router-view />
    <theme-picker />
  </div>
</template>

<script>
import ThemePicker from "@/components/ThemePicker";
import { reqLanguage } from "@/api/i18n";

export default {
  name: "App",
  components: { ThemePicker },
  metaInfo() {
    return {
      title:
        this.$store.state.settings.dynamicTitle &&
        this.$store.state.settings.title,
      titleTemplate: (title) => {
        return title
          ? `${title} - ${process.env.VUE_APP_TITLE}`
          : process.env.VUE_APP_TITLE;
      },
    };
  },
  created() {
    // let language = ["zh", "en", "ja"];
    // Promise.all(language.map(this.getLanguage)).then(() => {
    //   this.isDataLoaded = true;
    // });
  },
  methods: {
    // 获取语言包
    getLanguage(language) {
      // return reqLanguage(language).then((res) => {
      //   let info = res.info.reduce((obj, item) => {
      //     obj[item.Brief] = item.Describe;
      //     return obj;
      //   }, {});
      //   if (language === "en") {
      //     let obj = this.$i18n.getLocaleMessage(language);
      //     let messages = Object.assign({}, obj, {
      //       ...info,
      //     });
      //     this.$i18n.setLocaleMessage(language, messages);
      //   } else if (language === "zh") {
      //     let obj = this.$i18n.getLocaleMessage(language);
      //     let messages = Object.assign({}, obj, {
      //       ...info,
      //     });
      //     this.$i18n.setLocaleMessage(language, messages);
      //   } else if (language === "ja") {
      //     let obj = this.$i18n.getLocaleMessage(language);
      //     let messages = Object.assign({}, obj, {
      //       ...info,
      //     });
      //     this.$i18n.setLocaleMessage(language, messages);
      //   }
      // });
    },
  },
};
</script>
<style scoped>
#app .theme-picker {
  display: none;
}
</style>
